package logic

import (
	"context"

	"message/internal/svc"
	"message/pb/message"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStatusLogic {
	return &UpdateStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// UpdateStatus 撤回/删除消息
func (l *UpdateStatusLogic) UpdateStatus(in *message.UpdateStatusRequest) (*message.Empty, error) {
	err := l.svcCtx.MessageAggregationModel.UpdateMessage(l.ctx, in.Id, in.UserId, in.Status)
	if err != nil {
		return nil, err
	}
	return &message.Empty{}, nil
}
